import { createI18n } from 'vue-i18n';
import Cookies from 'js-cookie'

export const i18n = createI18n({
  legacy: false,
  locale:
    window.localStorage.getItem('lang') ||
    Cookies.get('lang') ||
    'en-US', // 语言标识
  messages: {
    'zh-CN': await import('./zh.json'),
    'en-US': await import('./en.json'),
    'pt-BR': await import('./pt.json'),
    'ja-JP': await import('./ja.json')
  }
})

export async function setupI18n(app) {
  app.use(i18n);
}